/*
 * $Id: ProtoBase.h,v 1.2 2005-06-28 10:53:20 bacon Exp $
 */

#ifndef _XPP_NET_PROTOBASE_CLASS_
#define _XPP_NET_PROTOBASE_CLASS_

#include <xpp/Uncopyable.h>
#include <xpp/net/Address.h>
#include <xpp/net/Transmittable.h>

namespace xpp
{
	namespace net
	{

		class ProtoBase: public Uncopyable 
		{
		public:
			ProtoBase (Transmittable* s = XP_NULL, Address* a = XP_NULL): 
				p_medium (s), p_address (a), p_errcode (ERR_NONE) {}
			virtual ~ProtoBase () {}

			Transmittable* medium () const
			{
				return p_medium;
			}
			void setMedium (Transmittable* s = XP_NULL) 
			{
				p_medium = s;
			}
		
			Address* address () const
			{
				return p_address;
			}
			void setAddress (Address* a = XP_NULL) 
			{
				p_address = a;
			}
		
			int errorCode () const 
			{
				return p_errcode;
			}
			void setErrorCode (int code) 
			{
				p_errcode = code;
			}

			const xp_char_t* errorStr () const;
		
			enum {
				ERR_NONE = 0, 
				ERR_RECEIVE,
				ERR_SEND,
				__NERRCODES__
			};
		
		protected:
			Transmittable* p_medium;
			Address*       p_address;
			int            p_errcode;
		};
		
	}
}
#endif
		
